﻿@model IEnumerable<web01.Models.DO.Persons>

<table class="table table-bordered table-striped table-hover table-condensed">
    <tr>
        <th>
            @Html.DisplayNameFor(mode=>mode.Id)
        </th>
        <th>
            @Html.DisplayNameFor(mode=>mode.Name)
        </th>
        <th> @Html.DisplayNameFor(mode=>mode.status)</th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @item.Id
            </td>
            <td> @item.Name</td>
            <td>
                @item.status
            </td>
        </tr>
    }
    
</table>
  <button onclick="oninint()">点击</button>
<script>
    
         
       function oninint(){
             alert("弹框");
             // 发送 POST 请求
             axios({
               method: 'post',
               url: '/ef/adduser',
                headers: {'context-type': 'application/json'},
               data: {
                 Id: 1,
                  Name: 'Flintstone',
                 status:1
               }
             }).then(function (response) {
                                  alert("成功")
                                console.log(response);
                              })
                              .catch(function (error) {
                                  alert("失败")
                                console.log(error);
                              });
             
        /*     // 为给定 ID 的 user 创建请求
             axios.post('/ef/adduser',{
                     Id: 1,
                     Name: 'Flintstone',
                     status:1
             })
               .then(function (response) {
                   alert("成功")
                 console.log(response);
               })
               .catch(function (error) {
                   alert("失败")
                 console.log(error);
               });*/
             
     /*   $.ajax({
            type:"post",
            url:"/ef/adduser",
            data: {"id":11,"Name":"哈哈","status":1},
            dataType: 'json',
            success: function (obj) {
                   console.log(obj.toString())
                                alert(""+obj.Success);
                  if (obj.Success === true) {
                      console.log(obj.toString())
                alert(""+obj.Success);
            } else {
                      console.log(obj.toString())
                                        alert('添加客户失败', obj.ResultMsg);
             }
            }*/
        }
 

</script>